package cn.it.shop.controller;

import java.util.HashMap;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.it.shop.wechat.common.JSSDK_Config;
import net.sf.json.JSONObject;

/**
 * ClassName: WeChatController
 * 
 * @Description: 前端用户微信配置获取
 * @author
 * @date
 */
@Controller
@RequestMapping("/wechatconfig")
public class WeChatController extends BaseController{
	
	
	/***
	 * 把js sdk配置参数封装为一个map
	 * @param url
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/jssdk")
	public String jssdk(@RequestParam(value = "url", required = true) String url){
		
		HashMap<String, String> map = new HashMap<String, String>();
		try {
			 //封装了所有js sdk配置参数的map
			 map = JSSDK_Config.jsSDK_Sign(url);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(JSONObject.fromObject(map).toString());
		return JSONObject.fromObject(map).toString();
	}
	
	
}
